import App from '@/App.vue';
import { useMenu } from '@/composable/menu';
import { useUser } from '@/composable/user';
import { useUserSystems } from '@/composable/user-systems';
import { staticRoutes } from '@/router';
import pinia from '@/store';
import { genRoutes } from '@/utils';
import { createApp } from 'vue';
import { createRouter, createWebHistory } from 'vue-router';
import 'uno.css';
import 'vxe-table/styles/cssvar.scss';
import 'vxe-table/lib/vxe-table/style';
import 'vxe-table/lib/vxe-column/style';

const rootApp = createApp(App);
rootApp.use(pinia);

const { getUserSystems } = useUserSystems();
const { getUser } = useUser();
const { getMenu } = useMenu();

await getUserSystems();
await getUser();
await getMenu();

const routes = genRoutes();

const router = createRouter({
  history: createWebHistory(BASE_URL),
  routes: [...routes, ...staticRoutes],
});
rootApp.use(router);

rootApp.mount('#root');
